import request from "@/request";

import type { responseType } from "./interface";

const prefix = "/courseListEntity";


/**
 * 查询-名称
 * @param {string} param
 * @returns
 */
export function selectCourseListByName(param: string): Promise<responseType> {
  return request.post(`${prefix}/selectCourseListByName/${param}`);
}

/**
 * 查询-编号
 * @param {string} param
 * @returns
 */
export function selectCourseListByID(param: string): Promise<responseType> {
  return request.post(`${prefix}/selectCourseListByID/${param}`);
}
/**
 * 查询-通过用户acc获取日报
 * @param {string} param
 * @returns
 */
export function getProjectByAcc(param: string): Promise<responseType> {
  return request.post(`${prefix}/getProjectByAcc/${param}`);
}
/**
 * 列表-分页
 * @param {string} page
 * @param {string} pageSize
 * @returns
 */
export function listPageCourseList(
  page: number,
  pageSize: number,
  name?: string,
  year?: number,
  teacherId?: string,
  teacherName?: string
): Promise<responseType> {
  year = 2024;
  return request.post(
    `${prefix}/listPageCourseList?page=${page}&pageSize=${pageSize}&name=${name}&year=${year}&teacherId=${teacherId}&teacherName=${teacherName}`
  );
}

// 参数接口
export interface InsertCourseListParams {
  id?: number;
  name?: string;
  teacher?: string;
  sort?: string;
  createBy?: string;
  createTime?: Record<string, unknown>;
  updateBy?: string;
  updateTime?: Record<string, unknown>;
  undock?: number;
  state?: number;
  remark?: string;
}


// 参数接口
export interface UpdateCourseListParams {
  id?: number;
  name?: string;
  sort?: string;
  createBy?: string;
  createTime?: Record<string, unknown>;
  updateBy?: string;
  updateTime?: Record<string, unknown>;
  undock?: number;
  state?: number;
  pro_description?: string;
  pro_requirement?: string;
}

/**
 * 创建项目
 * @param {object} params $!{table.comment}
 * @param {number} params.id 项目编号
 * @param {string} params.name 名称
 * @param {string} params.sort 排序
 * @param {string} params.createBy 创建者
 * @param {object} params.createTime 创建时间
 * @param {string} params.updateBy 更新者
 * @param {object} params.updateTime 更新时间
 * @param {number} params.undock 伪删除
 * @param {number} params.state 状态
 * @param {string} params.pro_description 项目简介
 * @param {string} params.pro_requirement 项目要求
 * @returns
 */
export function insertCourseList(
    params: UpdateCourseListParams
): Promise<responseType> {
  return request.post(`${prefix}/insert`, params);
}

//更新项目
export function updateCourseList(
    params: UpdateCourseListParams
): Promise<responseType> {
  return request.post(`${prefix}/update`, params);
}
/**
 * 删除
 * @param {string} param
 * @returns
 */
export function deleteCourseList(param: string): Promise<responseType> {
  return request.post(`${prefix}/delete/${param}`);
}

/**
 * 导入数据
 * @param {string} file
 * @returns
 */
export function importExcelCourseList(file: object): Promise<responseType> {
  return request.post(`${prefix}/importExcel?file=${file}`);
}

/**
 * 导出数据
 * @returns
 */
export function exportExcelCourseList(): Promise<responseType> {
  return request.post(`${prefix}/exportExcel`);
}